/*
* @Author: wanghongfucoder
* @Date:   2017-03-09 11:15:55
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-03-09 11:28:33
*/

public class Demo {
	
	/**
	 * [getMaleExpression description]
	 * @return [description]
	 * 规则：Robert和John是男性
	 */
	public static Expression getMaleExpression() {
		Expression robert=new TerminalExpression("Robert");
		Expression john=new TerminalExpression("John");
		return  new OrExpression(robert,john);
	}


	/**
	 * [getMarriedWomanExpression description]
	 * @return [description]
	 * 规则:Julie是一个已婚女性
	 */
	public static Expression getMarriedWomanExpression(){
		Expression julie=new TerminalExpression("Julie");
		Expression married=new TerminalExpression("Married");
		return new AndExpression(julie,married);
	}

	public static void main(String[] args) {
		Expression isMale=getMaleExpression();
		Expression isMarriedWoman=getMarriedWomanExpression();
		System.out.println("John is male"+isMale.interpret("John"));
		System.out.println("Julie is married women? "+isMarriedWoman.interpret("Married Julie"));
	}
}
